import {createApp} from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from "axios";

// 解决每次ajax请求 对应的sessionId不一致的问题 withCredentials - 凭证 证书
axios.defaults.withCredentials =true;

/**
 * axios 拦截器
 */
axios.interceptors.request.use(function (config) {
    // 请求头中添加用户 token
    let loginUser = JSON.parse(<string>sessionStorage.getItem("SESSION_KEY_LOGIN_USER")) as any || {};
    let token = loginUser.token;
    if (token !== null && token !== '' && token !== undefined) {
        config.headers.token = token;
    }
    console.log("请求：", config);
    return config;
}, error => {});
axios.interceptors.response.use(function (response) {
    console.log("返回结果：", response);
    return response;
}, error => {});

console.log("环境：", process.env.NODE_ENV)

createApp(App).use(store).use(router).mount('#app')
